<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePaymentAccountsTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('payment_accounts', function (Blueprint $table) {
            $table->id();
            $table->string('name', 50)->comment('账户名称');
            $table->tinyInteger('type')->default(1)->comment('1-银行账户, 2-收款二维码');
            $table->boolean('is_enabled')->default(true)->comment('是否启用');

            // 银行账户专属字段
            $table->string('bank_name', 50)->nullable()->comment('银行名称');
            $table->string('branch', 100)->nullable()->comment('支行名称');
            $table->string('account_name', 50)->nullable()->comment('开户名');
            $table->string('account_number', 30)->nullable()->comment('银行账号');

            // 二维码专属字段
            $table->tinyInteger('qrcode_type')->nullable()->comment('1-支付宝, 2-微信');
            $table->string('qrcode_image', 200)->nullable()->comment('二维码图片路径');
            $table->string('qrcode_url', 200)->nullable()->comment('二维码链接（可选）');

            // 公共信息
            $table->text('remarks')->nullable()->comment('备注信息');
            $table->timestamps();
        });
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `payment_accounts` comment '充值账户'");
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('payment_accounts');
    }
}
